package com.mycompany.dao.impl;

import com.mycompany.dao.PomodoroDAO;
import com.mycompany.entity.Pomodoro;
import javax.enterprise.inject.Alternative;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Alternative
public class PomodoroEMDAOImpl implements PomodoroDAO {

    @PersistenceContext(unitName="pomodoro")
    private EntityManager em;

    @Override
    public Pomodoro persist(Pomodoro t) {
        this.em.persist(t);
        this.em.flush();
        this.em.refresh(t);
        return t;
    }

    @Override
    public Pomodoro find(Object id) {
        return (Pomodoro) this.em.find(Pomodoro.class, id);
    }
    
    @Override
    public Pomodoro getReference(Pomodoro t) {
        return this.em.getReference(Pomodoro.class, t);
    }

    @Override
    public void remove(Pomodoro t) {
        this.em.remove(t);
    }

    @Override
    public Pomodoro merge(Pomodoro t) {
        this.em.merge(t);
        this.em.flush();
        this.em.refresh(t);
        return t;
    }
    
    @Override
    public void refresh(Pomodoro t) {
        this.em.refresh(t);
    }
    
}
